home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / tsbat45.zip / PROMPT.TXT < prev    next >
Text File  |  1993-01-04  |  5KB  |  130 lines

  1. (All rights reserved)                          Mon 4-January-1993
  2.  
  3. This PROMPT.TXT file contains prompt and related tips by
  4.  
  5. Prof. Timo Salmi                            
  6. Moderating at garbo.uwasa.fi anonymous FTP archives 128.214.87.1
  7. Faculty of Accounting & Industrial Management; University of Vaasa
  8. Internet: ts@uwasa.fi Bitnet: salmi@finfun   ; SF-65101, Finland
  9.  
  10. This file belongs to TSBAT*.ZIP.  Please do not distribute it
  11. separately.
  12.  
  13. 1) If you have programs that can shell to dos it would be nice to
  14. know whether you currently are in a dos shell or not. Else you might
  15. call the same program again from the shell and eventually run out of
  16. memory. There is a rather straight-forward trick for this. Assume
  17. that your program is called prog.exe. You can always call the
  18. program from a batch, say pro.bat. Include the following lines in
  19. your batch:
  20.  
  21.   set _prompt=%prompt%
  22.   set prompt=%_prompt%[in shell or whatever text]
  23.   prog %1 %2 %3 %4 %5 %6 %7 %8 %9
  24.   set prompt=%_prompt%
  25.   set prompt=
  26.  
  27. The method will not work or will produce unexpected results if the
  28. program itself manipulates the prompt when shelling to Dos. Some
  29. (usually advanced) programs do.
  30.  
  31. Another trick to avoid double loading is shown in the following
  32. skeleton
  33.   if "%_loaded%"=="yes" exit
  34.   set _loaded=yes
  35.   prog %1 %2 %3 %4 %5 %6 %7 %8 %9
  36.   set _loaded=
  37.  
  38.  
  39. 2) A frequently asked question about ansi.sys is now does one use it
  40. to redefine keyboard keys. Here is an example which redefines the F1
  41. key invoke the directory "dir" command, the F2 key to invoke the
  42. "dir/w" command, and the F3 to type the Scandinavian letter ä.
  43.    prompt $e[0;59;"dir";13p
  44.    prompt $e[0;60;"dir/w";13p
  45.    prompt $e[0;61;"ä"p
  46.    prompt $p$g
  47.  
  48. The last line is needed to restore the prompt in its usual format
  49. (which I have as $p$g).
  50.  
  51. To cancel the definitions apply
  52.    prompt $e[0;59;;p
  53.    prompt $e[0;60;;p
  54.    prompt $e[0;61;;p
  55.    prompt $p$g
  56.  
  57. This system requires that you have ansi.sys loaded in your
  58. config.sys file
  59.    device=c:\dos\ansi.sys
  60.  
  61. A related FAQ (Frequently Asked Question) is how to exchange the .
  62. and , keys.  here is how to do that
  63.   @echo <ESC>[",";"."p<ESC>[".";","p
  64. To reverse the effect, apply
  65.   @echo <ESC>[",";","p<ESC>[".";"."p
  66. This trick will not work for exchanging the CTRL and SHIFT keys.
  67. They are not mappable this way.
  68.  
  69. Note that ansi.sys replacements like zansi.sys (which I normally use
  70. myself) do not have the key-redefinition feature. This has one
  71. advantages, that is protecting you against the so-called ansi bombs.
  72.  
  73. The 0;59 pair defines F1 because it is that key's scan code. To get
  74. the scan codes of the different keys you need either a scan code
  75. table or a program that gives the scan code of the key you have
  76. pressed. One such program is SCANCODE.EXE in garbo.uwasa.fi:/pc/ts/
  77. tsbase11.zip (or whatever version number is the current).
  78.  
  79.  
  80. 3) You can devise quite complicated ansi prompts to do flashy
  81. things although much of this is rather computer entertainment than
  82. serious usage. Let look at some examples
  83.  
  84. My ordinary prompt is the simple
  85.    prompt $p$g
  86. which displays the directory followed bu the > sign. Furthermore I
  87. use bright yellow on black, but for that I apply echo <ESC>[40;33;1m
  88.  
  89. Let's build from that.
  90.    prompt $d $t$_$p$g
  91. Gives the date and the time on the first line ($d $t), then on the
  92. second ($_) gives the current directory ($p) and the > sign ($g).
  93.  
  94. Lets take a little more complicated example next:
  95.    prompt $e[s$e[1;69H$t$h$h$h$e[u$p$g
  96. This is of of the basic prompt tricks, and it puts the time in the
  97. upper right corner of the screen. First the current cursor postion
  98. is stored ($e[s); the cursor is moved to row 1, column 69 ($e[1;69H)
  99. the time is displayed ($t); the hundredths of a second are deleted
  100. ($h$h$h); the original cursor position is restored ($e[u); and
  101. finally the current directory and the > sign are displayed ($p$g).
  102.  
  103. The next obvious step is to display the time in some garish reverse.
  104. For the normal part of the prompt lets use my own default which is
  105. bright yellow on black ($e[40;33;1m).
  106.    prompt $e[s$e[1;69H$e[41;32;1m$t$e[40;33;1m$h$h$h$e[u$p$g
  107. The time is displayed in bright green on red ($e[41;32;1m).
  108.  
  109. The interpretation of the following prompt is left as an exercise:
  110.    prompt $e[s$e[H$e[43;30m$e[KDirectory $p $d $t $h$h$h$h $v
  111.           $e[40;33;1m$e[2;1H$e[K$e[u$p$g
  112. Note that you must have everything on one line only. The wrap here
  113. is just for readability.
  114.  
  115. One example of an "entertainment" prompt just to give the general
  116. idea:
  117.    prompt $e[s$_$e[40;37m██$e[34m██$e[37m████$_$e[34m████████
  118.           $e[40;37m$_██$e[34m██$e[37m████$e[40;33m $p$g
  119. Note that you must have everything on one line only. The wrap here
  120. is just for readability.
  121.  
  122. The difference in using the echo and the prompt for setting the
  123. screen colors is that the echo is invoked only when you apply it,
  124. but the prompt is called each time the dos prompt appears.
  125.  
  126.  
  127. 4) If you are having problems you can "debug" your prompt by giving
  128. the set command in MsDos which displays your environment variables
  129. including the prompt variable.
  130.